﻿// * Write a program that sorts an array of integers using the merge sort algorithm (find it in Wikipedia).

using System;

class MergeSortArray
{
    static void Main()
    {
        // read Array Size
        uint arraySize;
        do
        {
            Console.Write("Enter sorted array size: ");
        } while (!uint.TryParse(Console.ReadLine(), out arraySize));

        // read array elements
        int[] intArray = new int[arraySize];
        for (int i = 0; i < intArray.Length; i++)
        {
            do
            {
                Console.Write("Enter array elements {0}: ", i + 1);
            } while (!int.TryParse(Console.ReadLine(), out intArray[i]));
        }

        // merge sort


        // print sorted array
        Console.Write("Sorted Array: {");
        for (int i = 0; i < intArray.Length; i++)
        {
            Console.Write(intArray[i]);
            if (i != intArray.Length - 1)
            {
                Console.Write(", ");
            }
        }
        Console.WriteLine("}");
    }
}